<?php

namespace App\Models;


class CtcSettingModel
{
    public static function CtcSettingList($conn){
        $Sql="SELECT `id`, `name`, `path`,`trade_begin_time`,`trade_end_time`,`consult_price`,`system_price`,`up_down_base` FROM `ctc_setting` where `is_stop` <> 0 and `id` <> 2";
        return $conn->readConn($Sql,true);
    }
    /**
     * 查询产品配置
     * entry CtcSettingExample
     * return array
     * */
    public static function getCtcSettingInit($conn,$id){
        $Sql="select `id`, `name`, `path`,`consult_price`,`max_price`,`min_price`,`is_stop`,`is_stop_trade`,`commission`,`commission_set`,`transaction_amount`,`buy_num`,`sell_num`,`trade_begin_time`,`trade_end_time`,`is_stop_pub`,`up_down_base` from `ctc_setting` where `id` = $id";
        return $conn->readConn($Sql);
    }
    /**
     * 修改
     * entry $CtcSettingExample
     * return int
     * */
    public static function upCtcSettingInside($conn,$CtcSettingExample){
        $joinSql="";
        if($CtcSettingExample->phone !=null){
            $joinSql.=" `phone` = '$CtcSettingExample->phone',";
        }
        if($CtcSettingExample->consult_price !=null){
            $joinSql.=" `consult_price` = '$CtcSettingExample->consult_price',";
        }
        if($CtcSettingExample->max_price !=null){
            $joinSql.=" `max_price` = '$CtcSettingExample->max_price',";
        }
        if($CtcSettingExample->min_price !=null){
            $joinSql.=" `min_price` = '$CtcSettingExample->min_price',";
        }
        if($joinSql !=null){
            $innerJoin = rtrim($joinSql,",");
            $upUserSql="UPDATE  `ctc_setting` SET $innerJoin WHERE `id` = '$CtcSettingExample->id'";
            return $conn->executeConn($upUserSql);
        }
    }
}